import 'package:get/get.dart';
import 'package:ljy_p_app/constans/lj_constans.dart';
import 'package:shared_preferences/shared_preferences.dart';

class LjLaunchController extends GetxController {
  /// 是否登录
  var isLogin = false.obs;

  @override
  void onInit() async {
    super.onInit();
    SharedPreferences pref = await SharedPreferences.getInstance();
    isLogin.value = pref.getBool(LjConstans.isLoginKey) ?? false;
  }

  void loginSuccess() async {
    isLogin.value = true;
    
    SharedPreferences pref = await SharedPreferences.getInstance();
    pref.setBool(LjConstans.isLoginKey, true);
  }

  void loginOut() async {
    isLogin.value = false;

    SharedPreferences pref = await SharedPreferences.getInstance();
    pref.setBool(LjConstans.isLoginKey, false);
  }

}